﻿using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using T2V.SharePoint.Workflow;
using T2V.SharePoint.Common;


namespace T2V.SharePoint.Workflow
{
    public partial class ApprovalWFTaskFormConfirmation : TaskFormBase
    {
        protected override void OnInit(EventArgs e)
        {
            btnClose.Click += new EventHandler(btnClose_Click);
            
            base.OnLoad(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["TaskStatus"]))
                {
                    string taskStatusCode = Request.QueryString["TaskStatus"].ToString();
                    string taskStatus = string.Empty;

                    if (taskStatusCode == "Approved")
                    {
                        taskStatus = "duyệt";
                    }
                    else if (taskStatusCode == "Rejected")
                    {
                        taskStatus = "không duyệt";
                    }

                    if (!string.IsNullOrEmpty(taskStatus))
                    {
                        ltrConfirmation.Text = string.Format("Bạn đã chọn <span class='highlight-task-status'>{0}</span> đề nghị <a href='{1}?ID={2}'>{3}</a>.",
                            taskStatus,
                            CurrentWorkflowItem.ParentList.DefaultDisplayFormUrl,
                            this.CurrentWorkflowItem["ID"],
                            CurrentWorkflowItem.Title
                            );
                    }
                    else
                    {
                        Back();
                    }
                }
                else
                {
                    Back();
                }
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Back();
        }
    }
}
